#ifndef _jpeg_h_
#define _jpeg_h_

// jpeg.h
//
// jpeg file delegate

#include "delegates/io.h"

namespace simple{
    //
    // JPEG
    //
    // JPEG storage delegate

    class JPEGException : public Exception
    {
    public:
        JPEGException (std::string name="") 
            : Exception ("JPEGException: " + name) {}
    };


    class JPEG : public ImageIOBase
    {
    public:
        static JPEG& gOnly ();

        virtual DelegateInfo info (const std::string& filename);
        // Given data from the header of an image, return information
        // about this image, or indicate that nothing is known.

        virtual Image<RGB> readRGB   (const std::string& filename);
        virtual Image<Pel8>  readPel8  (const std::string& filename);

        virtual bool write (const std::string& filename, const RectImageStorage& pixels, const DelegateParams& params = sNoParams);

        // Default copy constructor and assignment operators ok.
    private:
        static JPEG* _sOnly;

        JPEG ();
        ~JPEG ();
    };


    // This object will make sure that jpeg is added to our supported list
    // during static initialization
    class JPEG_installer
    {
    public:
        static JPEG_installer installer;
    private:
        JPEG_installer ();
    };

}

#endif // _jpeg_h_
